﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StockStar.GatherData;
using System.Data.SqlClient;
using System.Data;

namespace Stockstar.Stock.Gather
{
    public static class NewsList
    {
        public static List<XgDetailEntity> XgListAll(string str)
        {
            List<XgDetailEntity> List = new List<XgDetailEntity>();
            SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.StrConn, CommandType.Text, "select id,url,flag,gpdm,createtime from XG_Detail where 1=1 " + str + " ", null);
            int i = 0;
            while (reader.Read())
            {
                i++;
                XgDetailEntity et = new XgDetailEntity();
                et.ID = int.Parse(reader["id"].ToString());
                et.Url = reader["url"].ToString();
                et.Gpdm = reader["gpdm"].ToString();
                et.Flag = int.Parse(reader["flag"].ToString());
                et.CreateTime = DateTime.Parse(reader["createtime"].ToString());
                List.Add(et);
            }
            Console.WriteLine("取到新股下" + i.ToString() + "条记录.");
            return List;
        }

        public static List<ZfDetailEntity> ZfListAll(string _str)
        {
            List<ZfDetailEntity> List = new List<ZfDetailEntity>();
            string sql = "select id,url,flag,createtime,stype from Zf_Detail where 1=1 " + _str + "";
            SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.StrConn, CommandType.Text, sql, null);
            while (reader.Read())
            {
                ZfDetailEntity et = new ZfDetailEntity();
                et.ID = int.Parse(reader["id"].ToString());
                et.Url = reader["url"].ToString();
                et.Flag = int.Parse(reader["flag"].ToString());
                et.CreateTime = DateTime.Parse(reader["createtime"].ToString());
                et.Stype = reader["stype"].ToString();
                List.Add(et);
            }
            return List;
        }


        public static List<KzzDetailEntity> KzzListAll(string _str)
        {
            List<KzzDetailEntity> List = new List<KzzDetailEntity>();
            string sql = "select id,url,flag,createtime,stype from Kzz_Detail where 1=1 " + _str + "";
            SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.StrConn, CommandType.Text, sql, null);
            while (reader.Read())
            {
                KzzDetailEntity et = new KzzDetailEntity();
                et.ID = int.Parse(reader["id"].ToString());
                et.Url = reader["url"].ToString();
                et.Flag = int.Parse(reader["flag"].ToString());
                et.CreateTime = DateTime.Parse(reader["createtime"].ToString());
                //et.Stype = int.Parse(reader["stype"].ToString());
                List.Add(et);
            }
            return List;
        }


        public static List<ShDetailEntity> ShListAll(string _str)
        {
            List<ShDetailEntity> List = new List<ShDetailEntity>();
            string sql = "select id,url,flag,createtime from Sh_Detail where 1=1 " + _str + "";
            SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.StrConn, CommandType.Text, sql, null);
            while (reader.Read())
            {
                ShDetailEntity et = new ShDetailEntity();
                et.ID = int.Parse(reader["id"].ToString());
                et.Url = reader["url"].ToString();
                et.Flag = int.Parse(reader["flag"].ToString());
                et.CreateTime = DateTime.Parse(reader["createtime"].ToString());
                List.Add(et);
            }
            return List;
        }

    }
}
